#include "sdlcondmutex.h"

SDLCondMutex::SDLCondMutex()
{
    //创建互斥锁
    m_mutex = SDL_CreateMutex();
    //创建条件变量
    m_cond = SDL_CreateCond();
}

SDLCondMutex::~SDLCondMutex(){
    SDL_DestroyMutex(m_mutex);
    SDL_DestroyCond(m_cond);
}

void SDLCondMutex::lock(){
    SDL_LockMutex(m_mutex);
}

void SDLCondMutex::unlock(){
    SDL_UnlockMutex(m_mutex);
}

void SDLCondMutex::signal(){
    SDL_CondSignal(m_cond);
}

void SDLCondMutex::broadcast(){
    SDL_CondBroadcast(m_cond);
}

void SDLCondMutex::wait(){
    SDL_CondWait(m_cond,m_mutex);
}
